package com.hdy.javachatroomdemo.Model;

import com.hdy.javachatroomdemo.Enum.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;
    public static <T>Result<T> success(ResultCodeEnum resultCodeEnum,T data) {
        Result<T>result=new Result<>(resultCodeEnum.getCode(),resultCodeEnum.getMsg(),data);
        return result;
    }
    public static <T>Result<T> fail(ResultCodeEnum resultCodeEnum) {
        Result<T>result=new Result<>(resultCodeEnum.getCode(),resultCodeEnum.getMsg(),null);
        return result;
    }
    public static <T>Result<T> fail(String msg,Integer code) {
        Result<T>result=new Result<>(code,msg,null);
        return result;
    }
}
